/*
 * @Author: zhang ke
 * @Date: 2025-06-27 14:45:54
 * @LastEditors: your name
 * @LastEditTime: 2025-06-27 16:49:25
 * @Description: 属性管理的接口
 * @FilePath: \vue3-admin\src\api\product\attr\index.ts
 */
import request from '@/utils/request'
import type {CategoryResponseData,AttrResponseData, Attr} from '@/api/product/attr/type'
// 统一管理接口
enum API{
  C1_URL = '/admin/product/getCategory1',
  C2_URL = '/admin/product/getCategory2/',
  C3_URL = '/admin/product/getCategory3/',
  ATTR_URL = '/admin/product/attrInfoList/',
  ADDORUPDATEATTR_URL = '/admin/product/saveAttrInfo',
  DELETEATTR_URL = '/admin/product/deleteAttr/',
}

// 获取一级分类接口
export const reqC1 = ()=>{
    return request.get<any,CategoryResponseData>(API.C1_URL)
}
// 获取二级分类接口
export const reqC2 = (category1Id:number|string)=>{
    return request.get<any,CategoryResponseData>(API.C2_URL + category1Id)
}
// 获取三级分类接口
export const reqC3 = (category2Id:number|string)=>{
    return request.get<any,CategoryResponseData>(API.C3_URL + category2Id)
}
//获取属性接口
 export const reqAttr = (category1Id:number|string,category2Id:number|string,category3Id:number|string)=>{
    return request.get<any,AttrResponseData>(API.ATTR_URL + `${category1Id}/${category2Id}/${category3Id}`)
 }

 //添加或更新属性接口
 export const reqAddOrUpdateAttr = (data:Attr)=>{
    return request.post<any,any>(API.ADDORUPDATEATTR_URL,data)
 }

 //删除属性的接口
 export const reqRemoveAttr = (attrId:number)=>{
    return request.delete<any,any>(API.DELETEATTR_URL + attrId)
 }